﻿using System;
using System.Collections.Generic;
using System.Text;
using TTClassLibrary;
using TTServer.Messages;
using libCommonClass;
using TTServer.Controller;
using bmttPPTController.TTServer;

namespace TTServer.MessageProcessor
{
    public class DSLoadRequestMessageProcessor : IMessageProcessor
    {
        public bool Process(libCommonClass.TTMessage message, libInterface.IClientInfoProvider clientInfoProvider)
        {
            if (message is DSLoadRequestMessage)
            {
                DSLoadRequestMessage msg = (DSLoadRequestMessage)message;

                if (!(clientInfoProvider.Authority == AuthorityConstant.ADMIN
                    || clientInfoProvider.Authority == AuthorityConstant.KEY_MEMBER))
                {
                    return true;
                }

                String filePath = msg.File;

                DrawingScreenManager instance = DrawingScreenManager.GetInstance();

                if (instance != null)
                {
                    instance.Load(filePath);
                }

                return true;
            }

            return false;
        }
    }
}
